/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package imclient;

import java.io.IOException;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;

/**
 * This class is the implementation class of the IChatService class. This class
 * will be used to send and receive messages between the client and the server.
 *
 * @author Andrew
 */
class ChatServiceStub implements IChatService {

    /*Method to send message. In its current implementation takes an object 
     * of the message class and returns "OK
     * @param Message
     * @return String
     * 
     */
    @Override
    public String sendMessage(Message parameter) {
        XMLReader reader = new XMLReader();
        String alertMessage = null;
        try {
            HashMap<String, String> hash = reader.readXML("config.xml");
            alertMessage = hash.get("validationAlert");

        } catch (Exception e) {
        }
        return alertMessage.toString();
    }


    /*Not Utilized in the current build
     * @decipricated
     */
    @Override
    public Message receiveMessage() throws Exception {
        Message returnedMessage = new Message();
        XMLReader reader = new XMLReader();
        HashMap<String, String> hash;
        String errorMessage = new String();
        try {
            hash = reader.readXML("config.xml");
            returnedMessage.setContent(hash.get("dummyMessage"));
            errorMessage = hash.get("errorMessage");
        } catch (Exception e) {
            
            JOptionPane.showInputDialog(errorMessage);
            
        
        
        }
          return returnedMessage;

    }
}
